<!DOCTYPE html>
<html lang="zh-Hans">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/all.min.css" integrity="sha256-2H3fkXt6FEmrReK448mDVGKb3WW2ZZw35gI7vqHOE4Y=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{&quot;hostname&quot;:&quot;www.nilstorm.com&quot;,&quot;root&quot;:&quot;&#x2F;&quot;,&quot;images&quot;:&quot;&#x2F;images&quot;,&quot;scheme&quot;:&quot;Gemini&quot;,&quot;version&quot;:&quot;8.5.0&quot;,&quot;exturl&quot;:false,&quot;sidebar&quot;:{&quot;position&quot;:&quot;left&quot;,&quot;display&quot;:&quot;post&quot;,&quot;padding&quot;:18,&quot;offset&quot;:12},&quot;copycode&quot;:false,&quot;bookmark&quot;:{&quot;enable&quot;:false,&quot;color&quot;:&quot;#222&quot;,&quot;save&quot;:&quot;auto&quot;},&quot;fancybox&quot;:false,&quot;mediumzoom&quot;:false,&quot;lazyload&quot;:false,&quot;pangu&quot;:false,&quot;comments&quot;:{&quot;style&quot;:&quot;tabs&quot;,&quot;active&quot;:null,&quot;storage&quot;:true,&quot;lazyload&quot;:false,&quot;nav&quot;:null},&quot;motion&quot;:{&quot;enable&quot;:true,&quot;async&quot;:false,&quot;transition&quot;:{&quot;post_block&quot;:&quot;fadeIn&quot;,&quot;post_header&quot;:&quot;fadeInDown&quot;,&quot;post_body&quot;:&quot;fadeInDown&quot;,&quot;coll_header&quot;:&quot;fadeInLeft&quot;,&quot;sidebar&quot;:&quot;fadeInUp&quot;}},&quot;prism&quot;:false,&quot;i18n&quot;:{&quot;placeholder&quot;:&quot;Searching...&quot;,&quot;empty&quot;:&quot;We didn&#39;t find any results for the search: ${query}&quot;,&quot;hits_time&quot;:&quot;${hits} results found in ${time} ms&quot;,&quot;hits&quot;:&quot;${hits} results found&quot;}}</script><script src="/js/config.js"></script>
<meta name="description" content="UWF_NULL_FIELD 翻译Field only ever set to null: …All writes to this field are of the constant value null, and thus all reads of the field will return null. Check for errors, or remove it if it is useles">
<meta property="og:type" content="article">
<meta property="og:title" content="FindBugs 规则整理：CORRECTNESS">
<meta property="og:url" content="http://www.nilstorm.com/2017/b2ff5786.html">
<meta property="og:site_name" content="Lam&#39;s Blog">
<meta property="og:description" content="UWF_NULL_FIELD 翻译Field only ever set to null: …All writes to this field are of the constant value null, and thus all reads of the field will return null. Check for errors, or remove it if it is useles">
<meta property="og:locale">
<meta property="og:image" content="https://tva1.sinaimg.cn/large/007S8ZIlgy1gee6wkfo69j30e9026gm4.jpg">
<meta property="article:published_time" content="2017-03-03T02:36:17.000Z">
<meta property="article:modified_time" content="2021-06-06T08:08:18.170Z">
<meta property="article:author" content="LinBinghe">
<meta property="article:tag" content="FindBugs">
<meta property="article:tag" content="规则">
<meta property="article:tag" content="CORRECTNESS">
<meta property="article:tag" content="翻译">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://tva1.sinaimg.cn/large/007S8ZIlgy1gee6wkfo69j30e9026gm4.jpg">


<link rel="canonical" href="http://www.nilstorm.com/2017/b2ff5786.html">



<script class="next-config" data-name="page" type="application/json">{&quot;sidebar&quot;:&quot;&quot;,&quot;isHome&quot;:false,&quot;isPost&quot;:true,&quot;lang&quot;:&quot;zh-Hans&quot;,&quot;comments&quot;:true,&quot;permalink&quot;:&quot;http:&#x2F;&#x2F;www.nilstorm.com&#x2F;2017&#x2F;b2ff5786.html&quot;,&quot;path&quot;:&quot;2017&#x2F;b2ff5786.html&quot;,&quot;title&quot;:&quot;FindBugs 规则整理：CORRECTNESS&quot;}</script>

<script class="next-config" data-name="calendar" type="application/json">&quot;&quot;</script>
<title>FindBugs 规则整理：CORRECTNESS | Lam's Blog</title>
  




  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<link rel="alternate" href="/atom.xml" title="Lam's Blog" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Toggle navigation bar" role="button">
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">Lam's Blog</h1>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">Knowledge as Action</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>







</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          Table of Contents
        </li>
        <li class="sidebar-nav-overview">
          Overview
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#UWF-NULL-FIELD"><span class="nav-number">1.</span> <span class="nav-text">UWF_NULL_FIELD</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#RCN-REDUNDANT-NULLCHECK-WOULD-HAVE-BEEN-A-NPE"><span class="nav-number">2.</span> <span class="nav-text">RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NP-GUARANTEED-DEREF-ON-EXCEPTION-PATH"><span class="nav-number">3.</span> <span class="nav-text">NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NP-NULL-ON-SOME-PATH-EXCEPTION"><span class="nav-number">4.</span> <span class="nav-text">NP_NULL_ON_SOME_PATH_EXCEPTION</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#EC-UNRELATED-TYPES"><span class="nav-number">5.</span> <span class="nav-text">EC_UNRELATED_TYPES</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#DMI-INVOKING-TOSTRING-ON-ARRAY"><span class="nav-number">6.</span> <span class="nav-text">DMI_INVOKING_TOSTRING_ON_ARRAY</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#UWF-UNWRITTEN-FIELD"><span class="nav-number">7.</span> <span class="nav-text">UWF_UNWRITTEN_FIELD</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#IL-INFINITE-RECURSIVE-LOOP"><span class="nav-number">8.</span> <span class="nav-text">IL_INFINITE_RECURSIVE_LOOP</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#FE-TEST-IF-EQUAL-TO-NOT-A-NUMBER"><span class="nav-number">9.</span> <span class="nav-text">FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#BC-IMPOSSIBLE-CAST"><span class="nav-number">10.</span> <span class="nav-text">BC_IMPOSSIBLE_CAST</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#BC-IMPOSSIBLE-DOWNCAST"><span class="nav-number">11.</span> <span class="nav-text">BC_IMPOSSIBLE_DOWNCAST</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#BC-IMPOSSIBLE-DOWNCAST-OF-TOARRAY"><span class="nav-number">12.</span> <span class="nav-text">BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#BC-IMPOSSIBLE-INSTANCEOF"><span class="nav-number">13.</span> <span class="nav-text">BC_IMPOSSIBLE_INSTANCEOF</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#BIT-AND"><span class="nav-number">14.</span> <span class="nav-text">BIT_AND</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#BIT-AND-ZZ"><span class="nav-number">15.</span> <span class="nav-text">BIT_AND_ZZ</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#BIT-IOR"><span class="nav-number">16.</span> <span class="nav-text">BIT_IOR</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#BIT-SIGNED-CHECK-HIGH-BIT"><span class="nav-number">17.</span> <span class="nav-text">BIT_SIGNED_CHECK_HIGH_BIT</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#BOA-BADLY-OVERRIDDEN-ADAPTER"><span class="nav-number">18.</span> <span class="nav-text">BOA_BADLY_OVERRIDDEN_ADAPTER</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#BX-UNBOXED-AND-COERCED-FOR-TERNARY-OPERATOR"><span class="nav-number">19.</span> <span class="nav-text">BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#DLS-DEAD-STORE-OF-CLASS-LITERAL"><span class="nav-number">20.</span> <span class="nav-text">DLS_DEAD_STORE_OF_CLASS_LITERAL</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#DLS-OVERWRITTEN-INCREMENT"><span class="nav-number">21.</span> <span class="nav-text">DLS_OVERWRITTEN_INCREMENT</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#DMI-BAD-MONTH"><span class="nav-number">22.</span> <span class="nav-text">DMI_BAD_MONTH</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#DMI-COLLECTIONS-SHOULD-NOT-CONTAIN-THEMSELVES"><span class="nav-number">23.</span> <span class="nav-text">DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#DMI-INVOKING-HASHCODE-ON-ARRAY"><span class="nav-number">24.</span> <span class="nav-text">DMI_INVOKING_HASHCODE_ON_ARRAY</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#DMI-LONG-BITS-TO-DOUBLE-INVOKED-ON-INT"><span class="nav-number">25.</span> <span class="nav-text">DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#DMI-VACUOUS-SELF-COLLECTION-CALL"><span class="nav-number">26.</span> <span class="nav-text">DMI_VACUOUS_SELF_COLLECTION_CALL</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#DMI-ANNOTATION-IS-NOT-VISIBLE-TO-REFLECTION"><span class="nav-number">27.</span> <span class="nav-text">DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#DMI-VACUOUS-CALL-TO-EASYMOCK-METHOD"><span class="nav-number">28.</span> <span class="nav-text">DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#EC-ARRAY-AND-NONARRAY"><span class="nav-number">29.</span> <span class="nav-text">EC_ARRAY_AND_NONARRAY</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#EC-INCOMPATIBLE-ARRAY-COMPARE"><span class="nav-number">30.</span> <span class="nav-text">EC_INCOMPATIBLE_ARRAY_COMPARE</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#EC-NULL-ARG"><span class="nav-number">31.</span> <span class="nav-text">EC_NULL_ARG</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#EC-UNRELATED-CLASS-AND-INTERFACE"><span class="nav-number">32.</span> <span class="nav-text">EC_UNRELATED_CLASS_AND_INTERFACE</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#EC-UNRELATED-INTERFACES"><span class="nav-number">33.</span> <span class="nav-text">EC_UNRELATED_INTERFACES</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#EC-UNRELATED-TYPES-USING-POINTER-EQUALITY"><span class="nav-number">34.</span> <span class="nav-text">EC_UNRELATED_TYPES_USING_POINTER_EQUALITY</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#EQ-ALWAYS-FALSE"><span class="nav-number">35.</span> <span class="nav-text">EQ_ALWAYS_FALSE</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#EQ-ALWAYS-TRUE"><span class="nav-number">36.</span> <span class="nav-text">EQ_ALWAYS_TRUE</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#EQ-COMPARING-CLASS-NAMES"><span class="nav-number">37.</span> <span class="nav-text">EQ_COMPARING_CLASS_NAMES</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#EQ-DONT-DEFINE-EQUALS-FOR-ENUM"><span class="nav-number">38.</span> <span class="nav-text">EQ_DONT_DEFINE_EQUALS_FOR_ENUM</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#EQ-OTHER-NO-OBJECT"><span class="nav-number">39.</span> <span class="nav-text">EQ_OTHER_NO_OBJECT</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#EQ-OTHER-USE-OBJECT"><span class="nav-number">40.</span> <span class="nav-text">EQ_OTHER_USE_OBJECT</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#EQ-OVERRIDING-EQUALS-NOT-SYMMETRIC"><span class="nav-number">41.</span> <span class="nav-text">EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#EQ-SELF-USE-OBJECT"><span class="nav-number">42.</span> <span class="nav-text">EQ_SELF_USE_OBJECT</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#VA-FORMAT-STRING-BAD-ARGUMENT"><span class="nav-number">43.</span> <span class="nav-text">VA_FORMAT_STRING_BAD_ARGUMENT</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#VA-FORMAT-STRING-BAD-CONVERSION"><span class="nav-number">44.</span> <span class="nav-text">VA_FORMAT_STRING_BAD_CONVERSION</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#VA-FORMAT-STRING-EXPECTED-MESSAGE-FORMAT-SUPPLIED"><span class="nav-number">45.</span> <span class="nav-text">VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#VA-FORMAT-STRING-EXTRA-ARGUMENTS-PASSED"><span class="nav-number">46.</span> <span class="nav-text">VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#VA-FORMAT-STRING-ILLEGAL"><span class="nav-number">47.</span> <span class="nav-text">VA_FORMAT_STRING_ILLEGAL</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#VA-FORMAT-STRING-MISSING-ARGUMENT"><span class="nav-number">48.</span> <span class="nav-text">VA_FORMAT_STRING_MISSING_ARGUMENT</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#VA-FORMAT-STRING-NO-PREVIOUS-ARGUMENT"><span class="nav-number">49.</span> <span class="nav-text">VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#GC-UNRELATED-TYPES"><span class="nav-number">50.</span> <span class="nav-text">GC_UNRELATED_TYPES</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#HE-SIGNATURE-DECLARES-HASHING-OF-UNHASHABLE-CLASS"><span class="nav-number">51.</span> <span class="nav-text">HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_CLASS</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#HE-USE-OF-UNHASHABLE-CLASS"><span class="nav-number">52.</span> <span class="nav-text">HE_USE_OF_UNHASHABLE_CLASS</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#ICAST-INT-CAST-TO-DOUBLE-PASSED-TO-CEIL"><span class="nav-number">53.</span> <span class="nav-text">ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#ICAST-INT-CAST-TO-FLOAT-PASSED-TO-ROUND"><span class="nav-number">54.</span> <span class="nav-text">ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#IJU-ASSERT-METHOD-INVOKED-FROM-RUN-METHOD"><span class="nav-number">55.</span> <span class="nav-text">IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#IJU-BAD-SUITE-METHOD"><span class="nav-number">56.</span> <span class="nav-text">IJU_BAD_SUITE_METHOD</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#IL-CONTAINER-ADDED-TO-ITSELF"><span class="nav-number">57.</span> <span class="nav-text">IL_CONTAINER_ADDED_TO_ITSELF</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#IL-INFINITE-LOOP"><span class="nav-number">58.</span> <span class="nav-text">IL_INFINITE_LOOP</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#IM-MULTIPLYING-RESULT-OF-IREM"><span class="nav-number">59.</span> <span class="nav-text">IM_MULTIPLYING_RESULT_OF_IREM</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#INT-BAD-COMPARISON-WITH-NONNEGATIVE-VALUE"><span class="nav-number">60.</span> <span class="nav-text">INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#INT-BAD-COMPARISON-WITH-SIGNED-BYTE"><span class="nav-number">61.</span> <span class="nav-text">INT_BAD_COMPARISON_WITH_SIGNED_BYTE</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#IO-APPENDING-TO-OBJECT-OUTPUT-STREAM"><span class="nav-number">62.</span> <span class="nav-text">IO_APPENDING_TO_OBJECT_OUTPUT_STREAM</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#IP-PARAMETER-IS-DEAD-BUT-OVERWRITTEN"><span class="nav-number">63.</span> <span class="nav-text">IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#MF-CLASS-MASKS-FIELD"><span class="nav-number">64.</span> <span class="nav-text">MF_CLASS_MASKS_FIELD</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#MF-METHOD-MASKS-FIELD"><span class="nav-number">65.</span> <span class="nav-text">MF_METHOD_MASKS_FIELD</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NP-ALWAYS-NULL"><span class="nav-number">66.</span> <span class="nav-text">NP_ALWAYS_NULL</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NP-ALWAYS-NULL-EXCEPTION"><span class="nav-number">67.</span> <span class="nav-text">NP_ALWAYS_NULL_EXCEPTION</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NP-ARGUMENT-MIGHT-BE-NULL"><span class="nav-number">68.</span> <span class="nav-text">NP_ARGUMENT_MIGHT_BE_NULL</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NP-CLOSING-NULL"><span class="nav-number">69.</span> <span class="nav-text">NP_CLOSING_NULL</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NP-GUARANTEED-DEREF"><span class="nav-number">70.</span> <span class="nav-text">NP_GUARANTEED_DEREF</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NP-NONNULL-PARAM-VIOLATION"><span class="nav-number">71.</span> <span class="nav-text">NP_NONNULL_PARAM_VIOLATION</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NP-NONNULL-RETURN-VIOLATION"><span class="nav-number">72.</span> <span class="nav-text">NP_NONNULL_RETURN_VIOLATION</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NP-NULL-INSTANCEOF"><span class="nav-number">73.</span> <span class="nav-text">NP_NULL_INSTANCEOF</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NP-NULL-ON-SOME-PATH"><span class="nav-number">74.</span> <span class="nav-text">NP_NULL_ON_SOME_PATH</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NP-NULL-PARAM-DEREF-ALL-TARGETS-DANGEROUS"><span class="nav-number">75.</span> <span class="nav-text">NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NP-STORE-INTO-NONNULL-FIELD"><span class="nav-number">76.</span> <span class="nav-text">NP_STORE_INTO_NONNULL_FIELD</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NM-BAD-EQUAL"><span class="nav-number">77.</span> <span class="nav-text">NM_BAD_EQUAL</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NM-LCASE-HASHCODE"><span class="nav-number">78.</span> <span class="nav-text">NM_LCASE_HASHCODE</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NM-LCASE-TOSTRING"><span class="nav-number">79.</span> <span class="nav-text">NM_LCASE_TOSTRING</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NM-METHOD-CONSTRUCTOR-CONFUSION"><span class="nav-number">80.</span> <span class="nav-text">NM_METHOD_CONSTRUCTOR_CONFUSION</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NM-VERY-CONFUSING"><span class="nav-number">81.</span> <span class="nav-text">NM_VERY_CONFUSING</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#NM-WRONG-PACKAGE"><span class="nav-number">82.</span> <span class="nav-text">NM_WRONG_PACKAGE</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#QBA-QUESTIONABLE-BOOLEAN-ASSIGNMENT"><span class="nav-number">83.</span> <span class="nav-text">QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#RC-REF-COMPARISON"><span class="nav-number">84.</span> <span class="nav-text">RC_REF_COMPARISON</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#RE-BAD-SYNTAX-FOR-REGULAR-EXPRESSION"><span class="nav-number">85.</span> <span class="nav-text">RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#RE-CANT-USE-FILE-SEPARATOR-AS-REGULAR-EXPRESSION"><span class="nav-number">86.</span> <span class="nav-text">RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#RV-01-TO-INT"><span class="nav-number">87.</span> <span class="nav-text">RV_01_TO_INT</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#RV-ABSOLUTE-VALUE-OF-HASHCODE"><span class="nav-number">88.</span> <span class="nav-text">RV_ABSOLUTE_VALUE_OF_HASHCODE</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#RV-ABSOLUTE-VALUE-OF-RANDOM-INT"><span class="nav-number">89.</span> <span class="nav-text">RV_ABSOLUTE_VALUE_OF_RANDOM_INT</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#RV-EXCEPTION-NOT-THROWN"><span class="nav-number">90.</span> <span class="nav-text">RV_EXCEPTION_NOT_THROWN</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#RV-RETURN-VALUE-IGNORED"><span class="nav-number">91.</span> <span class="nav-text">RV_RETURN_VALUE_IGNORED</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#RpC-REPEATED-CONDITIONAL-TEST"><span class="nav-number">92.</span> <span class="nav-text">RpC_REPEATED_CONDITIONAL_TEST</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#SA-FIELD-DOUBLE-ASSIGNMENT"><span class="nav-number">93.</span> <span class="nav-text">SA_FIELD_DOUBLE_ASSIGNMENT</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#SA-FIELD-SELF-ASSIGNMENT"><span class="nav-number">94.</span> <span class="nav-text">SA_FIELD_SELF_ASSIGNMENT</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#SA-FIELD-SELF-COMPARISON"><span class="nav-number">95.</span> <span class="nav-text">SA_FIELD_SELF_COMPARISON</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#SA-LOCAL-SELF-COMPARISON"><span class="nav-number">96.</span> <span class="nav-text">SA_LOCAL_SELF_COMPARISON</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#SA-LOCAL-SELF-COMPUTATION"><span class="nav-number">97.</span> <span class="nav-text">SA_LOCAL_SELF_COMPUTATION</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#SF-DEAD-STORE-DUE-TO-SWITCH-FALLTHROUGH"><span class="nav-number">98.</span> <span class="nav-text">SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#SF-DEAD-STORE-DUE-TO-SWITCH-FALLTHROUGH-TO-THROW"><span class="nav-number">99.</span> <span class="nav-text">SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#SIC-THREADLOCAL-DEADLY-EMBRACE"><span class="nav-number">100.</span> <span class="nav-text">SIC_THREADLOCAL_DEADLY_EMBRACE</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#SIO-SUPERFLUOUS-INSTANCEOF"><span class="nav-number">101.</span> <span class="nav-text">SIO_SUPERFLUOUS_INSTANCEOF</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#STI-INTERRUPTED-ON-CURRENTTHREAD"><span class="nav-number">102.</span> <span class="nav-text">STI_INTERRUPTED_ON_CURRENTTHREAD</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#STI-INTERRUPTED-ON-UNKNOWNTHREAD"><span class="nav-number">103.</span> <span class="nav-text">STI_INTERRUPTED_ON_UNKNOWNTHREAD</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#SE-METHOD-MUST-BE-PRIVATE"><span class="nav-number">104.</span> <span class="nav-text">SE_METHOD_MUST_BE_PRIVATE</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#SE-READ-RESOLVE-IS-STATIC"><span class="nav-number">105.</span> <span class="nav-text">SE_READ_RESOLVE_IS_STATIC</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#UMAC-UNCALLABLE-METHOD-OF-ANONYMOUS-CLASS"><span class="nav-number">106.</span> <span class="nav-text">UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#UR-UNINIT-READ"><span class="nav-number">107.</span> <span class="nav-text">UR_UNINIT_READ</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#UR-UNINIT-READ-CALLED-FROM-SUPER-CONSTRUCTOR"><span class="nav-number">108.</span> <span class="nav-text">UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%85%B6%E4%BB%96%E6%96%87%E7%AB%A0%EF%BC%88%E6%8C%81%E7%BB%AD%E6%9B%B4%E6%96%B0%EF%BC%89"><span class="nav-number">109.</span> <span class="nav-text">其他文章（持续更新）</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%BC%95%E7%94%A8"><span class="nav-number">110.</span> <span class="nav-text">引用</span></a></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="LinBinghe"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">LinBinghe</p>
  <div class="site-description" itemprop="description">Knowledge as Action</div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives">
          <span class="site-state-item-count">39</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
        <span class="site-state-item-count">13</span>
        <span class="site-state-item-name">categories</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
        <span class="site-state-item-count">60</span>
        <span class="site-state-item-name">tags</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author site-overview-item animated">
      <span class="links-of-author-item">
        <a href="https://github.com/LinBinghe" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;LinBinghe" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i></a>
      </span>
      <span class="links-of-author-item">
        <a href="https://www.zhihu.com/people/shawn_lam" title="Zhihu → https:&#x2F;&#x2F;www.zhihu.com&#x2F;people&#x2F;shawn_lam" rel="noopener" target="_blank"><i class="fab fa-zhihu fa-fw"></i></a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:linbinghe@gmail.com" title="E-Mail → mailto:linbinghe@gmail.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i></a>
      </span>
  </div>



        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="Back to top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-Hans">
    <link itemprop="mainEntityOfPage" href="http://www.nilstorm.com/2017/b2ff5786.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="LinBinghe">
      <meta itemprop="description" content="Knowledge as Action">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Lam's Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          FindBugs 规则整理：CORRECTNESS
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2017-03-03 10:36:17" itemprop="dateCreated datePublished" datetime="2017-03-03T10:36:17+08:00">2017-03-03</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">Edited on</span>
        <time title="Modified: 2021-06-06 16:08:18" itemprop="dateModified" datetime="2021-06-06T16:08:18+08:00">2021-06-06</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">In</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/FindBugs/" itemprop="url" rel="index"><span itemprop="name">FindBugs</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <h1 id="UWF-NULL-FIELD"><a href="#UWF-NULL-FIELD" class="headerlink" title="UWF_NULL_FIELD"></a>UWF_NULL_FIELD</h1><ul>
<li>翻译<br><em>Field only ever set to null: …</em><br><em>All writes to this field are of the constant value null, and thus all reads of the field will return null. Check for errors, or remove it if it is useless.</em><br>某个域的值一直都为null，导致所有读取到的该域的值也都是null，检查该域是否存在异常，或者移除这个无用的域</li>
<li>原因<br>在某个类里面我们定义了一个私有的成员变量，但是这个成员变量在实例范围内没有得到任何的初始化(采用默认的构造方法)，始终为null，所以在实例范围内使用该成员变量时，如果不先对其进行初始化操作或者无意识的行为忘了初始化操作，那肯定是要报空指针异常</li>
<li>解决方案<br>对该变量进行正确的赋值或者移除<span id="more"></span>
</li>
</ul>
<h1 id="RCN-REDUNDANT-NULLCHECK-WOULD-HAVE-BEEN-A-NPE"><a href="#RCN-REDUNDANT-NULLCHECK-WOULD-HAVE-BEEN-A-NPE" class="headerlink" title="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"></a>RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE</h1><ul>
<li>翻译<br><em>Nullcheck of form at line .. of value previously dereferenced in …<br>A value is checked here to see whether it is null, but this value can’t be null because it was previously dereferenced and if it were null a null pointer exception would have occurred at the earlier dereference. Essentially, this code and the previous dereference disagree as to whether this value is allowed to be null. Either the check is redundant or the previous dereference is erroneous.</em><br>某个值虽然在某处有被判断是否为null，但是这个值在该处并不可以为null，因为这个值被提前引用了，如果他有可能是null，在被引用的时候就会产生空指针异常，所以这里的判断也就是多余的，而在该判断之前的引用也可能是错误的。</li>
<li>原因<br>判断某个值是否为null的时机错误</li>
<li>解决方案<br>修改判断时机等，视具体情况而定</li>
</ul>
<h1 id="NP-GUARANTEED-DEREF-ON-EXCEPTION-PATH"><a href="#NP-GUARANTEED-DEREF-ON-EXCEPTION-PATH" class="headerlink" title="NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH"></a>NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH</h1><ul>
<li>翻译<br><em>.. is null guaranteed to be dereferenced in … on exception path<br>There is a statement or branch on an exception path that if executed guarantees that a value is null at this point, and that value that is guaranteed to be dereferenced (except on forward paths involving runtime exceptions).</em><br>在某个异常发生时候某个值将会被置为null，而该null值会被引用</li>
<li>原因<br>比如我们在finally中调用了一个在异常发生时则无法正常初始化的对象，这时候就可能产生空指针等异常</li>
<li>解决方案<br>判断每个分支中所引用的值在各种情况下是否符合预期，避免产生异常</li>
</ul>
<h1 id="NP-NULL-ON-SOME-PATH-EXCEPTION"><a href="#NP-NULL-ON-SOME-PATH-EXCEPTION" class="headerlink" title="NP_NULL_ON_SOME_PATH_EXCEPTION"></a>NP_NULL_ON_SOME_PATH_EXCEPTION</h1><ul>
<li>翻译<br><em>Possible null pointer dereference of .. in … on exception path<br>A reference value which is null on some exception control path is dereferenced here. This may lead to a NullPointerException when the code is executed. Note that because FindBugs currently does not prune infeasible exception paths, this may be a false warning.<br>Also note that FindBugs considers the default case of a switch statement to be an exception path, since the default case is often infeasible.</em><br>因为某些异常路径的发生导致部分对象无法正常初始化，但后续该对象仍会被调用从而产生空指针异常。由于FindBgus无法去除不会执行的异常路径，所以这也可能是一个错误的警告。</li>
<li>原因<br>同NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH </li>
<li>解决方案<br>同NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH </li>
</ul>
<h1 id="EC-UNRELATED-TYPES"><a href="#EC-UNRELATED-TYPES" class="headerlink" title="EC_UNRELATED_TYPES"></a>EC_UNRELATED_TYPES</h1><ul>
<li>翻译<br><em>Call to String.equals(Double) in …<br>This method calls equals(Object) on two references of different class types with no common subclasses. Therefore, the objects being compared are unlikely to be members of the same class at runtime (unless some application classes were not analyzed, or dynamic class loading can occur at runtime). According to the contract of equals(), objects of different classes should always compare as unequal; therefore, according to the contract defined by java.lang.Object.equals(Object), the result of this comparison will always be false at runtime.</em><br>两个不同的类的实例通过equals方法，通常情况下都会判断为非相同对象，其返回值也将始终为false。</li>
<li>原因<br>如第一行所说，调用string的equals方法比较double类型，永远都会返回false，如果把这个作为逻辑判断是没有意义的</li>
<li>解决方案<br>去除这种无意义的判断</li>
</ul>
<h1 id="DMI-INVOKING-TOSTRING-ON-ARRAY"><a href="#DMI-INVOKING-TOSTRING-ON-ARRAY" class="headerlink" title="DMI_INVOKING_TOSTRING_ON_ARRAY"></a>DMI_INVOKING_TOSTRING_ON_ARRAY</h1><ul>
<li>翻译<br><em>Invocation of toString on … in …<br>The code invokes toString on an array, which will generate a fairly useless result such as [C@16f0472. Consider using Arrays.toString to convert the array into a readable String that gives the contents of the array. See Programming Puzzlers, chapter 3, puzzle 12.</em><br>在一个array数组上调用toString将返回如C@16f0472等无意义的结果，可以使用Arrays.toString方法来将数组转换为可读的字符串。</li>
<li>原因<br>大多数这个问题出在直接打印某个数组是否为空，而FindBugs不知道此处只是log日志，这种直接打印的方法会默认调用对象的toString方法，输出对象的内存地址，也不排除其他情况。</li>
<li>解决方案<br>如果是日志可以选择不处理或者隐藏日志，其他情况则视具体情况而定。</li>
</ul>
<h1 id="UWF-UNWRITTEN-FIELD"><a href="#UWF-UNWRITTEN-FIELD" class="headerlink" title="UWF_UNWRITTEN_FIELD"></a>UWF_UNWRITTEN_FIELD</h1><ul>
<li>翻译<br><em>Unwritten field: …<br>This field is never written. All reads of it will return the default value. Check for errors (should it have been initialized?), or remove it if it is useless.</em><br>某个域没有被赋值过，所有对这个变量的读取都会获得默认值，检查该变量是否存在异常，或者移除这个无用的变量</li>
<li>原因<br>变量只有默认值，后续没有再进行任何赋值过</li>
<li>解决方案<br>判断是否存在使用上的异常，或者抽取为final常量等，视情况而定</li>
</ul>
<h1 id="IL-INFINITE-RECURSIVE-LOOP"><a href="#IL-INFINITE-RECURSIVE-LOOP" class="headerlink" title="IL_INFINITE_RECURSIVE_LOOP"></a>IL_INFINITE_RECURSIVE_LOOP</h1><ul>
<li>翻译<br><em>There is an apparent infinite recursive loop in …<br>This method unconditionally invokes itself. This would seem to indicate an infinite recursive loop that will result in a stack overflow.</em><br>在某处存在死循环。</li>
<li>原因<br>如无跳出条件的递归等造成的死循环</li>
<li>解决方案<br>修改出现死循环的代码</li>
</ul>
<h1 id="FE-TEST-IF-EQUAL-TO-NOT-A-NUMBER"><a href="#FE-TEST-IF-EQUAL-TO-NOT-A-NUMBER" class="headerlink" title="FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER"></a>FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER</h1><p><em>Doomed test for equality to NaN<br>This code checks to see if a floating point value is equal to the special Not A Number value (e.g., if (x == Double.NaN)). However, because of the special semantics of NaN, no value is equal to Nan, including NaN. Thus, x == Double.NaN always evaluates to false. To check to see if a value contained in x is the special Not A Number value, use Double.isNaN(x) (or Float.isNaN(x) if x is floating point precision).</em><br>判断是否与NaN相等，但是并不会有值与NaN相等，所以这个判断永远返回false</p>
<h1 id="BC-IMPOSSIBLE-CAST"><a href="#BC-IMPOSSIBLE-CAST" class="headerlink" title="BC_IMPOSSIBLE_CAST"></a>BC_IMPOSSIBLE_CAST</h1><p><em>Impossible cast</em><br>不可能的类转换，执行时会抛出ClassCastException</p>
<h1 id="BC-IMPOSSIBLE-DOWNCAST"><a href="#BC-IMPOSSIBLE-DOWNCAST" class="headerlink" title="BC_IMPOSSIBLE_DOWNCAST"></a>BC_IMPOSSIBLE_DOWNCAST</h1><p><em>Impossible downcast</em><br>父类在向下进行类型转换时抛出ClassCastException</p>
<h1 id="BC-IMPOSSIBLE-DOWNCAST-OF-TOARRAY"><a href="#BC-IMPOSSIBLE-DOWNCAST-OF-TOARRAY" class="headerlink" title="BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY"></a>BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY</h1><ul>
<li>翻译<br><em>This code is casting the result of calling toArray() on a collection to a type more specific than Object[], as in:<br>String[] getAsArray(Collection<String> c) {<br>return (String[]) c.toArray();<br>}<br>This will usually fail by throwing a ClassCastException. The toArray() of almost all collections return an Object[]. They can’t really do anything else, since the Collection object has no reference to the declared generic type of the collection.<br>The correct way to do get an array of a specific type from a collection is to use c.toArray(new String[]); or c.toArray(new String[c.size()]); (the latter is slightly more efficient). </em><br>某段代码调用Collection.toArray方法获得一组对Object数组更具体的对象数组，这通常会导致ClassCastException。toArray方法大多数集合会返回Object[]，它们不能做其他实际的事情，因为集合对象没有声明泛型类型的引用</li>
<li>原因<br>集合转换为数组元素时发生的类转换错误。</li>
<li>解决方案<br>使用Collection.toArray(new String[]) 或者Collection.toArray(new String[Collection.size()]) 转换</li>
</ul>
<h1 id="BC-IMPOSSIBLE-INSTANCEOF"><a href="#BC-IMPOSSIBLE-INSTANCEOF" class="headerlink" title="BC_IMPOSSIBLE_INSTANCEOF"></a>BC_IMPOSSIBLE_INSTANCEOF</h1><p><em>Instanceof will always return false</em><br>采用instaneof方法进行比较时总是返回false。前提是保证它不是由于某些逻辑错误造成的。</p>
<h1 id="BIT-AND"><a href="#BIT-AND" class="headerlink" title="BIT_AND"></a>BIT_AND</h1><p><em>Incompatible bit masks</em><br>错误的使用&amp;位操作符，例如(e &amp; C)</p>
<h1 id="BIT-AND-ZZ"><a href="#BIT-AND-ZZ" class="headerlink" title="BIT_AND_ZZ"></a>BIT_AND_ZZ</h1><p><em>Check to see if ((…) &amp; 0) == 0</em><br>检查恒等的逻辑错误</p>
<h1 id="BIT-IOR"><a href="#BIT-IOR" class="headerlink" title="BIT_IOR"></a>BIT_IOR</h1><p><em>Incompatible bit masks</em><br>错误的使用|位操作符，例如(e | C)</p>
<h1 id="BIT-SIGNED-CHECK-HIGH-BIT"><a href="#BIT-SIGNED-CHECK-HIGH-BIT" class="headerlink" title="BIT_SIGNED_CHECK_HIGH_BIT"></a>BIT_SIGNED_CHECK_HIGH_BIT</h1><p><em>Check for sign of bitwise operation</em><br>检查逻辑运算符操作返回的标识。例如((event.detail &amp; SWT.SELECTED) &gt; 0)，建议采用 !=0 代替 &gt;0</p>
<h1 id="BOA-BADLY-OVERRIDDEN-ADAPTER"><a href="#BOA-BADLY-OVERRIDDEN-ADAPTER" class="headerlink" title="BOA_BADLY_OVERRIDDEN_ADAPTER"></a>BOA_BADLY_OVERRIDDEN_ADAPTER</h1><p><em>Class overrides a method implemented in super class Adapter wrongly</em><br>子类错误的覆写父类中用于适配监听其他事件的方法，从而导致当触发条件发生时不能被监听者调用</p>
<h1 id="BX-UNBOXED-AND-COERCED-FOR-TERNARY-OPERATOR"><a href="#BX-UNBOXED-AND-COERCED-FOR-TERNARY-OPERATOR" class="headerlink" title="BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR"></a>BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR</h1><p><em>Primitive value is unboxed and coerced for ternary operator</em><br>在三元运算符操作时如果没有对值进行封装或者类型转换。例如：b ? e1 : e2</p>
<h1 id="DLS-DEAD-STORE-OF-CLASS-LITERAL"><a href="#DLS-DEAD-STORE-OF-CLASS-LITERAL" class="headerlink" title="DLS_DEAD_STORE_OF_CLASS_LITERAL"></a>DLS_DEAD_STORE_OF_CLASS_LITERAL</h1><p><em>Dead store of class literal</em><br>以类的字面名称方式为一个字段赋值后再也没有去使用它，在1.4jdk中它会自动调用静态的初始化方法，而在jdk1.5中却不会去执行。</p>
<h1 id="DLS-OVERWRITTEN-INCREMENT"><a href="#DLS-OVERWRITTEN-INCREMENT" class="headerlink" title="DLS_OVERWRITTEN_INCREMENT"></a>DLS_OVERWRITTEN_INCREMENT</h1><p><em>Overwritten increment</em><br>覆写增量增加错误i = i++</p>
<h1 id="DMI-BAD-MONTH"><a href="#DMI-BAD-MONTH" class="headerlink" title="DMI_BAD_MONTH"></a>DMI_BAD_MONTH</h1><p><em>Bad constant value for month</em><br>表示月份的错误常量值</p>
<h1 id="DMI-COLLECTIONS-SHOULD-NOT-CONTAIN-THEMSELVES"><a href="#DMI-COLLECTIONS-SHOULD-NOT-CONTAIN-THEMSELVES" class="headerlink" title="DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES"></a>DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES</h1><p><em>Collections should not contain themselves</em><br>集合不应该包含他们自己本身。</p>
<h1 id="DMI-INVOKING-HASHCODE-ON-ARRAY"><a href="#DMI-INVOKING-HASHCODE-ON-ARRAY" class="headerlink" title="DMI_INVOKING_HASHCODE_ON_ARRAY"></a>DMI_INVOKING_HASHCODE_ON_ARRAY</h1><p><em>Invocation of hashCode on an array</em><br>在数组上调用了hashCode</p>
<h1 id="DMI-LONG-BITS-TO-DOUBLE-INVOKED-ON-INT"><a href="#DMI-LONG-BITS-TO-DOUBLE-INVOKED-ON-INT" class="headerlink" title="DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT"></a>DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT</h1><p><em>Double.longBitsToDouble invoked on an int</em><br>在int上调用了Double.longBitsToDouble</p>
<h1 id="DMI-VACUOUS-SELF-COLLECTION-CALL"><a href="#DMI-VACUOUS-SELF-COLLECTION-CALL" class="headerlink" title="DMI_VACUOUS_SELF_COLLECTION_CALL"></a>DMI_VACUOUS_SELF_COLLECTION_CALL</h1><p><em>Vacuous call to collections</em><br>集合的调用不能被感知。例如c.containsAll(c)总是返回true，而c.retainAll(c)的返回值不能被感知。</p>
<h1 id="DMI-ANNOTATION-IS-NOT-VISIBLE-TO-REFLECTION"><a href="#DMI-ANNOTATION-IS-NOT-VISIBLE-TO-REFLECTION" class="headerlink" title="DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION"></a>DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION</h1><p><em>Can’t use reflection to check for presence of annotation without runtime retention</em><br>不能使用反射检测没有标记为runtime rentention的注解的存在</p>
<h1 id="DMI-VACUOUS-CALL-TO-EASYMOCK-METHOD"><a href="#DMI-VACUOUS-CALL-TO-EASYMOCK-METHOD" class="headerlink" title="DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD"></a>DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD</h1><p><em>Useless/vacuous call to EasyMock method</em><br>EasyMock方法的无用/空调用</p>
<h1 id="EC-ARRAY-AND-NONARRAY"><a href="#EC-ARRAY-AND-NONARRAY" class="headerlink" title="EC_ARRAY_AND_NONARRAY"></a>EC_ARRAY_AND_NONARRAY</h1><p><em>equals() used to compare array and nonarray</em><br>数组对象使用equals方法和非数组对象进行比较。即使比较的双方都是数组对象也不应该使用equals方法，而应该比较它们的内容是否相等使用java.util.Arrays.equals(Object[], Object[]);<br>使用指针比较不同的类型</p>
<h1 id="EC-INCOMPATIBLE-ARRAY-COMPARE"><a href="#EC-INCOMPATIBLE-ARRAY-COMPARE" class="headerlink" title="EC_INCOMPATIBLE_ARRAY_COMPARE"></a>EC_INCOMPATIBLE_ARRAY_COMPARE</h1><p><em>equals(…) used to compare incompatible arrays</em><br>使用equls方法去比较类型不相同的数组。例如：String[] and StringBuffer[], or String[] and int[]</p>
<h1 id="EC-NULL-ARG"><a href="#EC-NULL-ARG" class="headerlink" title="EC_NULL_ARG"></a>EC_NULL_ARG</h1><p><em>Call to equals() with null argument</em><br>调用equals的对象为null</p>
<h1 id="EC-UNRELATED-CLASS-AND-INTERFACE"><a href="#EC-UNRELATED-CLASS-AND-INTERFACE" class="headerlink" title="EC_UNRELATED_CLASS_AND_INTERFACE"></a>EC_UNRELATED_CLASS_AND_INTERFACE</h1><p><em>Call to equals() comparing unrelated class and interface</em><br>使用equals方法比较不相关的类和接口</p>
<h1 id="EC-UNRELATED-INTERFACES"><a href="#EC-UNRELATED-INTERFACES" class="headerlink" title="EC_UNRELATED_INTERFACES"></a>EC_UNRELATED_INTERFACES</h1><p><em>Call to equals() comparing different interface types</em><br>调用equals方法比较不同类型的接口</p>
<h1 id="EC-UNRELATED-TYPES-USING-POINTER-EQUALITY"><a href="#EC-UNRELATED-TYPES-USING-POINTER-EQUALITY" class="headerlink" title="EC_UNRELATED_TYPES_USING_POINTER_EQUALITY"></a>EC_UNRELATED_TYPES_USING_POINTER_EQUALITY</h1><p><em>Using pointer equality to compare different types</em><br>使用指针比较不同的类型</p>
<h1 id="EQ-ALWAYS-FALSE"><a href="#EQ-ALWAYS-FALSE" class="headerlink" title="EQ_ALWAYS_FALSE"></a>EQ_ALWAYS_FALSE</h1><p><em>equals method always returns false</em><br>使用equals方法返回值总是false</p>
<h1 id="EQ-ALWAYS-TRUE"><a href="#EQ-ALWAYS-TRUE" class="headerlink" title="EQ_ALWAYS_TRUE"></a>EQ_ALWAYS_TRUE</h1><p><em>equals method always returns true</em><br>equals方法返回值总是true</p>
<h1 id="EQ-COMPARING-CLASS-NAMES"><a href="#EQ-COMPARING-CLASS-NAMES" class="headerlink" title="EQ_COMPARING_CLASS_NAMES"></a>EQ_COMPARING_CLASS_NAMES</h1><p><em>equals method compares class names rather than class objects</em><br>equals方法比较类名而不是比较类</p>
<h1 id="EQ-DONT-DEFINE-EQUALS-FOR-ENUM"><a href="#EQ-DONT-DEFINE-EQUALS-FOR-ENUM" class="headerlink" title="EQ_DONT_DEFINE_EQUALS_FOR_ENUM"></a>EQ_DONT_DEFINE_EQUALS_FOR_ENUM</h1><p>Covariant equals() method defined for enum<br>为枚举类型定义了equals()方法</p>
<h1 id="EQ-OTHER-NO-OBJECT"><a href="#EQ-OTHER-NO-OBJECT" class="headerlink" title="EQ_OTHER_NO_OBJECT"></a>EQ_OTHER_NO_OBJECT</h1><p><em>equals() method defined that doesn’t override equals(Object)</em><br>定义equals()方法，但是没有覆盖equals(Object)</p>
<h1 id="EQ-OTHER-USE-OBJECT"><a href="#EQ-OTHER-USE-OBJECT" class="headerlink" title="EQ_OTHER_USE_OBJECT"></a>EQ_OTHER_USE_OBJECT</h1><p><em>equals() method defined that doesn’t override Object.equals(Object)</em><br> 定义equals()方法，但是没有覆盖Object.equals(Object)</p>
<h1 id="EQ-OVERRIDING-EQUALS-NOT-SYMMETRIC"><a href="#EQ-OVERRIDING-EQUALS-NOT-SYMMETRIC" class="headerlink" title="EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC"></a>EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC</h1><p><em>equals method overrides equals in superclass and may not be symmetric</em><br>equals方法覆盖了父类的equals可能功能不符</p>
<h1 id="EQ-SELF-USE-OBJECT"><a href="#EQ-SELF-USE-OBJECT" class="headerlink" title="EQ_SELF_USE_OBJECT"></a>EQ_SELF_USE_OBJECT</h1><p><em>Covariant equals() method defined, Object.equals(Object) inherited</em><br>类中定义了一组equals方法，但是都是继承的java.lang.Object class中的equals(Object)方法</p>
<h1 id="VA-FORMAT-STRING-BAD-ARGUMENT"><a href="#VA-FORMAT-STRING-BAD-ARGUMENT" class="headerlink" title="VA_FORMAT_STRING_BAD_ARGUMENT"></a>VA_FORMAT_STRING_BAD_ARGUMENT</h1><p><em>Format string placeholder incompatible with passed argument</em><br>格式化字符串占位符与传入的参数不匹配</p>
<h1 id="VA-FORMAT-STRING-BAD-CONVERSION"><a href="#VA-FORMAT-STRING-BAD-CONVERSION" class="headerlink" title="VA_FORMAT_STRING_BAD_CONVERSION"></a>VA_FORMAT_STRING_BAD_CONVERSION</h1><p><em>The type of a supplied argument doesn’t match format specifier</em><br>指定的格式字符串和参数类型不匹配，例如：String.format(“%d”, “1”)</p>
<h1 id="VA-FORMAT-STRING-EXPECTED-MESSAGE-FORMAT-SUPPLIED"><a href="#VA-FORMAT-STRING-EXPECTED-MESSAGE-FORMAT-SUPPLIED" class="headerlink" title="VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED"></a>VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED</h1><p><em>MessageFormat supplied where printf style format expected</em><br>需要使用printf样式时却使用了MessageFormat，从而引起格式化结果出错</p>
<h1 id="VA-FORMAT-STRING-EXTRA-ARGUMENTS-PASSED"><a href="#VA-FORMAT-STRING-EXTRA-ARGUMENTS-PASSED" class="headerlink" title="VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED"></a>VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED</h1><p><em>More arguments are passed than are actually used in the format string</em><br>使用字符串格式化时传递了多余的参数</p>
<h1 id="VA-FORMAT-STRING-ILLEGAL"><a href="#VA-FORMAT-STRING-ILLEGAL" class="headerlink" title="VA_FORMAT_STRING_ILLEGAL"></a>VA_FORMAT_STRING_ILLEGAL</h1><p><em>Illegal format string</em><br>格式化String对象语句错误</p>
<h1 id="VA-FORMAT-STRING-MISSING-ARGUMENT"><a href="#VA-FORMAT-STRING-MISSING-ARGUMENT" class="headerlink" title="VA_FORMAT_STRING_MISSING_ARGUMENT"></a>VA_FORMAT_STRING_MISSING_ARGUMENT</h1><p><em>Format string references missing argument</em><br>String的format操作缺少必要的参数。</p>
<h1 id="VA-FORMAT-STRING-NO-PREVIOUS-ARGUMENT"><a href="#VA-FORMAT-STRING-NO-PREVIOUS-ARGUMENT" class="headerlink" title="VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT"></a>VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT</h1><p><em>No previous argument for format string</em><br>格式字符串定义错误，例如：formatter.format(“%&lt;s %s”, “a”, “b”); 抛出MissingFormatArgumentException异常</p>
<h1 id="GC-UNRELATED-TYPES"><a href="#GC-UNRELATED-TYPES" class="headerlink" title="GC_UNRELATED_TYPES"></a>GC_UNRELATED_TYPES</h1><p><em>No relationship between generic parameter and method argument</em><br>泛型参数与方法参数没有相互关系</p>
<h1 id="HE-SIGNATURE-DECLARES-HASHING-OF-UNHASHABLE-CLASS"><a href="#HE-SIGNATURE-DECLARES-HASHING-OF-UNHASHABLE-CLASS" class="headerlink" title="HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_CLASS"></a>HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_CLASS</h1><p><em>Signature declares use of unhashable class in hashed construct</em><br>在哈希构造中声明了无法使用哈希算法的类</p>
<h1 id="HE-USE-OF-UNHASHABLE-CLASS"><a href="#HE-USE-OF-UNHASHABLE-CLASS" class="headerlink" title="HE_USE_OF_UNHASHABLE_CLASS"></a>HE_USE_OF_UNHASHABLE_CLASS</h1><p><em>Use of class without a hashCode() method in a hashed data structure</em><br>在哈希数据结构中使用的类没有定义hashCode()方法</p>
<h1 id="ICAST-INT-CAST-TO-DOUBLE-PASSED-TO-CEIL"><a href="#ICAST-INT-CAST-TO-DOUBLE-PASSED-TO-CEIL" class="headerlink" title="ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL"></a>ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL</h1><p><em>integral value cast to double and then passed to Math.ceil</em><br>integral的值转换为double后使用了Math.ceil方法</p>
<h1 id="ICAST-INT-CAST-TO-FLOAT-PASSED-TO-ROUND"><a href="#ICAST-INT-CAST-TO-FLOAT-PASSED-TO-ROUND" class="headerlink" title="ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND"></a>ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND</h1><p><em>int value cast to float and then passed to Math.round</em><br>int 类型的值转换为float类型之后调用了Math.round方法</p>
<h1 id="IJU-ASSERT-METHOD-INVOKED-FROM-RUN-METHOD"><a href="#IJU-ASSERT-METHOD-INVOKED-FROM-RUN-METHOD" class="headerlink" title="IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD"></a>IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD</h1><p><em>JUnit assertion in run method will not be noticed by JUnit</em><br>在JUnit中的断言在run方法中不会被告知</p>
<h1 id="IJU-BAD-SUITE-METHOD"><a href="#IJU-BAD-SUITE-METHOD" class="headerlink" title="IJU_BAD_SUITE_METHOD"></a>IJU_BAD_SUITE_METHOD</h1><p><em>TestCase declares a bad suite method</em><br>在一个JUnit类中声明的一个suite()方法必须声明为 public static junit.framework.Test suite() 或者 public static junit.framework.TestSuite suite() 的形式。</p>
<h1 id="IL-CONTAINER-ADDED-TO-ITSELF"><a href="#IL-CONTAINER-ADDED-TO-ITSELF" class="headerlink" title="IL_CONTAINER_ADDED_TO_ITSELF"></a>IL_CONTAINER_ADDED_TO_ITSELF</h1><p><em>A collection is added to itself</em><br>集合本身作为add方法的参数，这样会引起内存溢出。</p>
<h1 id="IL-INFINITE-LOOP"><a href="#IL-INFINITE-LOOP" class="headerlink" title="IL_INFINITE_LOOP"></a>IL_INFINITE_LOOP</h1><p><em>An apparent infinite loop</em><br>无法跳出的递归方法引起的死循环</p>
<h1 id="IM-MULTIPLYING-RESULT-OF-IREM"><a href="#IM-MULTIPLYING-RESULT-OF-IREM" class="headerlink" title="IM_MULTIPLYING_RESULT_OF_IREM"></a>IM_MULTIPLYING_RESULT_OF_IREM</h1><p><em>Integer multiply of result of integer remainder</em><br>和整数余数进行乘法运算。例如：i % 60 <em> 1000 是进行(i % 60) </em> 1000运算而不是 i % (60 * 1000)</p>
<h1 id="INT-BAD-COMPARISON-WITH-NONNEGATIVE-VALUE"><a href="#INT-BAD-COMPARISON-WITH-NONNEGATIVE-VALUE" class="headerlink" title="INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE"></a>INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE</h1><p><em>Bad comparison of nonnegative value with negative constant</em><br>错误地比较非负数与负数</p>
<h1 id="INT-BAD-COMPARISON-WITH-SIGNED-BYTE"><a href="#INT-BAD-COMPARISON-WITH-SIGNED-BYTE" class="headerlink" title="INT_BAD_COMPARISON_WITH_SIGNED_BYTE"></a>INT_BAD_COMPARISON_WITH_SIGNED_BYTE</h1><p><em>Bad comparison of signed byte</em><br>比较有符合数，要先把有符号数转换为无符合数再进行比较</p>
<h1 id="IO-APPENDING-TO-OBJECT-OUTPUT-STREAM"><a href="#IO-APPENDING-TO-OBJECT-OUTPUT-STREAM" class="headerlink" title="IO_APPENDING_TO_OBJECT_OUTPUT_STREAM"></a>IO_APPENDING_TO_OBJECT_OUTPUT_STREAM</h1><p><em>Doomed attempt to append to an object output stream</em><br>试图在对象的输出流处添加元素，如果你希望能够添加进一个对象的输出流中，那么必须保证对象的输出流处于打开状态。</p>
<h1 id="IP-PARAMETER-IS-DEAD-BUT-OVERWRITTEN"><a href="#IP-PARAMETER-IS-DEAD-BUT-OVERWRITTEN" class="headerlink" title="IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN"></a>IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN</h1><p><em>A parameter is dead upon entry to a method but overwritten</em><br>传入参数的值没有被使用，但是对传入值进行了修改，并返回给了调用者</p>
<h1 id="MF-CLASS-MASKS-FIELD"><a href="#MF-CLASS-MASKS-FIELD" class="headerlink" title="MF_CLASS_MASKS_FIELD"></a>MF_CLASS_MASKS_FIELD</h1><p><em>Class defines field that masks a superclass field </em><br>子类中定义了和父类中同名的字段。在调用时会出错</p>
<h1 id="MF-METHOD-MASKS-FIELD"><a href="#MF-METHOD-MASKS-FIELD" class="headerlink" title="MF_METHOD_MASKS_FIELD"></a>MF_METHOD_MASKS_FIELD</h1><p><em>Method defines a variable that obscures a field</em><br>在方法中定义的局部变量和类变量或者父类变量同名，从而引起字段混淆。</p>
<h1 id="NP-ALWAYS-NULL"><a href="#NP-ALWAYS-NULL" class="headerlink" title="NP_ALWAYS_NULL"></a>NP_ALWAYS_NULL</h1><p><em>Null pointer dereference</em><br>对象赋为null值后 没有被重新赋值</p>
<h1 id="NP-ALWAYS-NULL-EXCEPTION"><a href="#NP-ALWAYS-NULL-EXCEPTION" class="headerlink" title="NP_ALWAYS_NULL_EXCEPTION"></a>NP_ALWAYS_NULL_EXCEPTION</h1><p><em>Null pointer dereference in method on exception path</em><br>方法的异常路径中引用了空指针</p>
<h1 id="NP-ARGUMENT-MIGHT-BE-NULL"><a href="#NP-ARGUMENT-MIGHT-BE-NULL" class="headerlink" title="NP_ARGUMENT_MIGHT_BE_NULL"></a>NP_ARGUMENT_MIGHT_BE_NULL</h1><p><em>Method does not check for null argument</em><br>方法没有判断参数是否为空</p>
<h1 id="NP-CLOSING-NULL"><a href="#NP-CLOSING-NULL" class="headerlink" title="NP_CLOSING_NULL"></a>NP_CLOSING_NULL</h1><p><em>close() invoked on a value that is always null</em><br>一个为空的对象调用close方法</p>
<h1 id="NP-GUARANTEED-DEREF"><a href="#NP-GUARANTEED-DEREF" class="headerlink" title="NP_GUARANTEED_DEREF"></a>NP_GUARANTEED_DEREF</h1><p><em>Null value is guaranteed to be dereferenced</em><br>存在一定会被调用的null对象</p>
<h1 id="NP-NONNULL-PARAM-VIOLATION"><a href="#NP-NONNULL-PARAM-VIOLATION" class="headerlink" title="NP_NONNULL_PARAM_VIOLATION"></a>NP_NONNULL_PARAM_VIOLATION</h1><p><em>Method call passes null to a nonnull parameter</em><br>方法中为null的参数没有被重新赋值</p>
<h1 id="NP-NONNULL-RETURN-VIOLATION"><a href="#NP-NONNULL-RETURN-VIOLATION" class="headerlink" title="NP_NONNULL_RETURN_VIOLATION"></a>NP_NONNULL_RETURN_VIOLATION</h1><p><em>Method may return null, but is declared @NonNull</em><br>方法声明了返回值不能为空，但是方法中有可能返回null</p>
<h1 id="NP-NULL-INSTANCEOF"><a href="#NP-NULL-INSTANCEOF" class="headerlink" title="NP_NULL_INSTANCEOF"></a>NP_NULL_INSTANCEOF</h1><p><em>A known null value is checked to see if it is an instance of a type</em><br>一个已知的null值被用来判断它是否是一个类型的实例</p>
<h1 id="NP-NULL-ON-SOME-PATH"><a href="#NP-NULL-ON-SOME-PATH" class="headerlink" title="NP_NULL_ON_SOME_PATH"></a>NP_NULL_ON_SOME_PATH</h1><p><em>Possible null pointer dereference</em><br>可能出现空指针引用</p>
<h1 id="NP-NULL-PARAM-DEREF-ALL-TARGETS-DANGEROUS"><a href="#NP-NULL-PARAM-DEREF-ALL-TARGETS-DANGEROUS" class="headerlink" title="NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS"></a>NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS</h1><p><em>method call passes null for nonnull parameter </em><br>方法参数中声明为nonnull类型的参数为null</p>
<h1 id="NP-STORE-INTO-NONNULL-FIELD"><a href="#NP-STORE-INTO-NONNULL-FIELD" class="headerlink" title="NP_STORE_INTO_NONNULL_FIELD"></a>NP_STORE_INTO_NONNULL_FIELD</h1><p><em>Store of null value into field annotated NonNull</em><br>一个已经声明为不能为null值的属性被赋值为null。</p>
<h1 id="NM-BAD-EQUAL"><a href="#NM-BAD-EQUAL" class="headerlink" title="NM_BAD_EQUAL"></a>NM_BAD_EQUAL</h1><p><em>Class defines equal(Object); should it be equals(Object)?</em><br>类中定义了一个equal方法但是却不是覆写的Object对象的equals方法</p>
<h1 id="NM-LCASE-HASHCODE"><a href="#NM-LCASE-HASHCODE" class="headerlink" title="NM_LCASE_HASHCODE"></a>NM_LCASE_HASHCODE</h1><p><em>Class defines hashcode(); should it be hashCode()?</em><br>类中定义了一个hashCode方法但是却不是覆写的Object中的hashCode方法</p>
<h1 id="NM-LCASE-TOSTRING"><a href="#NM-LCASE-TOSTRING" class="headerlink" title="NM_LCASE_TOSTRING"></a>NM_LCASE_TOSTRING</h1><p><em>Class defines tostring(); should it be toString()?</em><br>类中定义了一个toString方法但是却不是覆写的Object中的toString方法</p>
<h1 id="NM-METHOD-CONSTRUCTOR-CONFUSION"><a href="#NM-METHOD-CONSTRUCTOR-CONFUSION" class="headerlink" title="NM_METHOD_CONSTRUCTOR_CONFUSION"></a>NM_METHOD_CONSTRUCTOR_CONFUSION</h1><p><em>Apparent method/constructor confusion</em><br>构造方法定义混乱</p>
<h1 id="NM-VERY-CONFUSING"><a href="#NM-VERY-CONFUSING" class="headerlink" title="NM_VERY_CONFUSING"></a>NM_VERY_CONFUSING</h1><p><em>Very confusing method names</em><br>混乱的方法命名，如getName和getname方法同时出现的时候</p>
<h1 id="NM-WRONG-PACKAGE"><a href="#NM-WRONG-PACKAGE" class="headerlink" title="NM_WRONG_PACKAGE"></a>NM_WRONG_PACKAGE</h1><p><em>Method doesn’t override method in superclass due to wrong package for parameter</em><br>因为包名不正确所以没能正确覆盖父类的方法</p>
<h1 id="QBA-QUESTIONABLE-BOOLEAN-ASSIGNMENT"><a href="#QBA-QUESTIONABLE-BOOLEAN-ASSIGNMENT" class="headerlink" title="QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT"></a>QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT</h1><p><em>Method assigns boolean literal in boolean expression</em><br>在if或者while表达式中使用boolean类型的值时应该使用==去判断，而不是采用=操作</p>
<h1 id="RC-REF-COMPARISON"><a href="#RC-REF-COMPARISON" class="headerlink" title="RC_REF_COMPARISON"></a>RC_REF_COMPARISON</h1><p><em>Suspicious reference comparison</em><br>比较两个对象值是否相等时应该采用equals方法，而不是==方法</p>
<h1 id="RE-BAD-SYNTAX-FOR-REGULAR-EXPRESSION"><a href="#RE-BAD-SYNTAX-FOR-REGULAR-EXPRESSION" class="headerlink" title="RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION"></a>RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION</h1><p><em>Invalid syntax for regular expression</em><br>对正则表达式使用了错误的语法，会抛出未经检查的异常</p>
<h1 id="RE-CANT-USE-FILE-SEPARATOR-AS-REGULAR-EXPRESSION"><a href="#RE-CANT-USE-FILE-SEPARATOR-AS-REGULAR-EXPRESSION" class="headerlink" title="RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION"></a>RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION</h1><p><em>File.separator used for regular expression</em><br>在正则表达式中使用了错误的文件分隔符，在windows系统中正则表达式不会匹配’\’而应该使用’\‘</p>
<h1 id="RV-01-TO-INT"><a href="#RV-01-TO-INT" class="headerlink" title="RV_01_TO_INT"></a>RV_01_TO_INT</h1><p><em>Random value from 0 to 1 is coerced to the integer 0</em><br>从0到1随机值被强制为整数值0。在强制得到一个整数之前，你可能想得到多个随机值。可以使用Random.nextInt（n）的方法。</p>
<h1 id="RV-ABSOLUTE-VALUE-OF-HASHCODE"><a href="#RV-ABSOLUTE-VALUE-OF-HASHCODE" class="headerlink" title="RV_ABSOLUTE_VALUE_OF_HASHCODE"></a>RV_ABSOLUTE_VALUE_OF_HASHCODE</h1><p><em>Bad attempt to compute absolute value of signed 32-bit hashcode</em><br>此代码生成一个哈希码，然后计算该哈希码的绝对值。如果哈希码是Integer.MIN<em>VALUE的，那么结果将是负数（因为Math.abs（Integer.MIN_VALUE的）== Integer.MIN_VALUE的）。<br>在2^ 32值之外字符串有一个Integer.MIN_VALUE的hashCode包括“polygenelubricants”，“GydZG</em>”和“，”DESIGNING WORKHOUSES “。</p>
<h1 id="RV-ABSOLUTE-VALUE-OF-RANDOM-INT"><a href="#RV-ABSOLUTE-VALUE-OF-RANDOM-INT" class="headerlink" title="RV_ABSOLUTE_VALUE_OF_RANDOM_INT"></a>RV_ABSOLUTE_VALUE_OF_RANDOM_INT</h1><p><em>Bad attempt to compute absolute value of signed 32-bit random integer</em><br>此代码生成一个随机的符号整数，然后计算该随机整数的绝对值。如果随机数生成数绝对值为Integer.MIN_VALUE的，那么结果将是负数（因为Math.abs（Integer.MIN_VALUE的）== Integer.MIN_VALUE的）。</p>
<h1 id="RV-EXCEPTION-NOT-THROWN"><a href="#RV-EXCEPTION-NOT-THROWN" class="headerlink" title="RV_EXCEPTION_NOT_THROWN"></a>RV_EXCEPTION_NOT_THROWN</h1><p><em>Exception created and dropped rather than thrown</em><br>此代码创建一个异常（或错误）的对象，但不会用它做任何事情。</p>
<h1 id="RV-RETURN-VALUE-IGNORED"><a href="#RV-RETURN-VALUE-IGNORED" class="headerlink" title="RV_RETURN_VALUE_IGNORED"></a>RV_RETURN_VALUE_IGNORED</h1><p><em>Method ignores return value</em><br>方法忽略了返回值，应该对返回值进行检查</p>
<h1 id="RpC-REPEATED-CONDITIONAL-TEST"><a href="#RpC-REPEATED-CONDITIONAL-TEST" class="headerlink" title="RpC_REPEATED_CONDITIONAL_TEST"></a>RpC_REPEATED_CONDITIONAL_TEST</h1><p><em>Repeated conditional tests</em><br>该代码包含对同一个条件试验了两次，两边完全一样例如：（如X == 0 | | x == 0）。可能第二次出现是打算判断别的不同条件（如X == 0 | | y== 0）。</p>
<h1 id="SA-FIELD-DOUBLE-ASSIGNMENT"><a href="#SA-FIELD-DOUBLE-ASSIGNMENT" class="headerlink" title="SA_FIELD_DOUBLE_ASSIGNMENT"></a>SA_FIELD_DOUBLE_ASSIGNMENT</h1><p><em>Double assignment of field</em><br>对属性进行双重赋值</p>
<h1 id="SA-FIELD-SELF-ASSIGNMENT"><a href="#SA-FIELD-SELF-ASSIGNMENT" class="headerlink" title="SA_FIELD_SELF_ASSIGNMENT"></a>SA_FIELD_SELF_ASSIGNMENT</h1><p><em>Self assignment of field</em><br>属性自身赋值</p>
<h1 id="SA-FIELD-SELF-COMPARISON"><a href="#SA-FIELD-SELF-COMPARISON" class="headerlink" title="SA_FIELD_SELF_COMPARISON"></a>SA_FIELD_SELF_COMPARISON</h1><p><em>Self comparison of field with itself</em><br>属性自己与自己进行了比较</p>
<h1 id="SA-LOCAL-SELF-COMPARISON"><a href="#SA-LOCAL-SELF-COMPARISON" class="headerlink" title="SA_LOCAL_SELF_COMPARISON"></a>SA_LOCAL_SELF_COMPARISON</h1><p><em>Self comparison of value with itself</em><br>自己和自己的值比较</p>
<h1 id="SA-LOCAL-SELF-COMPUTATION"><a href="#SA-LOCAL-SELF-COMPUTATION" class="headerlink" title="SA_LOCAL_SELF_COMPUTATION"></a>SA_LOCAL_SELF_COMPUTATION</h1><p><em>Nonsensical self computation involving a variable (e.g., x &amp; x)</em><br>此方法对同一变量执行了无意义的计算（如x&amp;x或x-x）操作。由于计算的性质，这一行动似乎没有意义，并可能表明错误或逻辑错误。</p>
<h1 id="SF-DEAD-STORE-DUE-TO-SWITCH-FALLTHROUGH"><a href="#SF-DEAD-STORE-DUE-TO-SWITCH-FALLTHROUGH" class="headerlink" title="SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH"></a>SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH</h1><p><em>Dead store due to switch statement fall through</em><br>在swtich中先前的case值因为swtich执行失败而被覆写，这就像是忘记使用break推出或者没有使用return语句放回先前的值一样。</p>
<h1 id="SF-DEAD-STORE-DUE-TO-SWITCH-FALLTHROUGH-TO-THROW"><a href="#SF-DEAD-STORE-DUE-TO-SWITCH-FALLTHROUGH-TO-THROW" class="headerlink" title="SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW"></a>SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW</h1><p><em>Dead store due to switch statement fall through to throw</em><br>在swtich中因为出现异常而忽略了对case值的保存。</p>
<h1 id="SIC-THREADLOCAL-DEADLY-EMBRACE"><a href="#SIC-THREADLOCAL-DEADLY-EMBRACE" class="headerlink" title="SIC_THREADLOCAL_DEADLY_EMBRACE"></a>SIC_THREADLOCAL_DEADLY_EMBRACE</h1><p><em>Deadly embrace of non-static inner class and thread local</em><br>如果线程包含对一个内部类实例的引用，那么内外实例的实例都可以被获取，这样就不具备垃圾会回收的资格。</p>
<h1 id="SIO-SUPERFLUOUS-INSTANCEOF"><a href="#SIO-SUPERFLUOUS-INSTANCEOF" class="headerlink" title="SIO_SUPERFLUOUS_INSTANCEOF"></a>SIO_SUPERFLUOUS_INSTANCEOF</h1><p><em>Unnecessary type check done using instanceof operator</em><br>在进行instanceof操作时进行没有必要的类型检查</p>
<h1 id="STI-INTERRUPTED-ON-CURRENTTHREAD"><a href="#STI-INTERRUPTED-ON-CURRENTTHREAD" class="headerlink" title="STI_INTERRUPTED_ON_CURRENTTHREAD"></a>STI_INTERRUPTED_ON_CURRENTTHREAD</h1><p><em>Unneeded use of currentThread() call, to call interrupted()</em><br>此方法调用Thread.currentThread()，只需调用interrupted()方法。由于interrupted（）是一个静态方法， Thread.interrupted()更简单易用。</p>
<h1 id="STI-INTERRUPTED-ON-UNKNOWNTHREAD"><a href="#STI-INTERRUPTED-ON-UNKNOWNTHREAD" class="headerlink" title="STI_INTERRUPTED_ON_UNKNOWNTHREAD"></a>STI_INTERRUPTED_ON_UNKNOWNTHREAD</h1><p><em>Thread.interrupted() method invoked on thread instance</em><br>调用不是当前线程对象的Thread.interrupted()方法，由于interrupted（）方法是静态的，interrupted方法将会调用一个和作者原计划不同的对象。</p>
<h1 id="SE-METHOD-MUST-BE-PRIVATE"><a href="#SE-METHOD-MUST-BE-PRIVATE" class="headerlink" title="SE_METHOD_MUST_BE_PRIVATE"></a>SE_METHOD_MUST_BE_PRIVATE</h1><p><em>Method must be private in order for serialization to work</em><br>这个类实现了Serializable接口，并定义自定义序列化的方法/反序列化。但这种方法不能声明为private，否则将被序列化/反序列化的API忽略掉。</p>
<h1 id="SE-READ-RESOLVE-IS-STATIC"><a href="#SE-READ-RESOLVE-IS-STATIC" class="headerlink" title="SE_READ_RESOLVE_IS_STATIC"></a>SE_READ_RESOLVE_IS_STATIC</h1><p><em>The readResolve method must not be declared as a static method.</em><br>为使readResolve方法得到序列化机制的识别，不能作为一个静态方法来声明。</p>
<h1 id="UMAC-UNCALLABLE-METHOD-OF-ANONYMOUS-CLASS"><a href="#UMAC-UNCALLABLE-METHOD-OF-ANONYMOUS-CLASS" class="headerlink" title="UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS"></a>UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS</h1><p><em>Uncallable method defined in anonymous class</em><br>在匿名类中定义了一个既没有覆写超类中方法也不能直接调用的方法，因为在其他类的方法不能直接引用匿名类声明的方法，似乎这种方法不能被调用，这种方法可能只是没有任何作用的代码，但也可能是覆写超类中声明。</p>
<h1 id="UR-UNINIT-READ"><a href="#UR-UNINIT-READ" class="headerlink" title="UR_UNINIT_READ"></a>UR_UNINIT_READ</h1><p><em>Uninitialized read of field in constructor</em><br>此构造方法中使用了一个尚未赋值的字段或属性。</p>
<h1 id="UR-UNINIT-READ-CALLED-FROM-SUPER-CONSTRUCTOR"><a href="#UR-UNINIT-READ-CALLED-FROM-SUPER-CONSTRUCTOR" class="headerlink" title="UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR"></a>UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR</h1><p><em>Uninitialized read of field method called from constructor of superclass</em><br>父类的构造方法调用未初始化属性的方法</p>
<h1 id="其他文章（持续更新）"><a href="#其他文章（持续更新）" class="headerlink" title="其他文章（持续更新）"></a>其他文章（持续更新）</h1><p><a target="_blank" rel="noopener" href="http://linbinghe.me/2017/b8a60a5e.html">FindBugs：简介与使用</a><br><a target="_blank" rel="noopener" href="http://linbinghe.me/2017/f6c077f9.html">FindBugs 规则整理：Bad Practice</a><br><a target="_blank" rel="noopener" href="http://linbinghe.me/2017/eb74f6c5.html">FindBugs 规则整理：Style &amp; Dodgy</a><br><a target="_blank" rel="noopener" href="http://linbinghe.me/2017/7dfffed7.html">FindBugs 规则整理：Malicious Code Vulnerability</a><br><a target="_blank" rel="noopener" href="http://linbinghe.me/2017/baebe2db.html">FindBugs 规则整理：Multithreaded Correctness</a><br><a target="_blank" rel="noopener" href="http://linbinghe.me/2017/27613e18.html">FindBugs 规则整理：Security &amp; Experimental</a><br><a target="_blank" rel="noopener" href="http://linbinghe.me/2017/8a8d645f.html">FindBugs 规则整理：Performance</a><br><a target="_blank" rel="noopener" href="http://linbinghe.me/2017/7a2a5923.html">FindBugs 规则整理：Internationalization</a></p>
<h1 id="引用"><a href="#引用" class="headerlink" title="引用"></a>引用</h1><p><em>整合以下文章过程中发现部分存在翻译错误，已做修正，同时感谢以下文章作者</em><br><a target="_blank" rel="noopener" href="https://my.oschina.net/hoodlake/blog/126735">FindBugs使用备忘录</a><br><a target="_blank" rel="noopener" href="http://blog.csdn.net/jdsjlzx/article/details/21472253/">FindBugs规则整理</a><br> <a target="_blank" rel="noopener" href="http://blog.csdn.net/yang1982_0907/article/details/18606171">详解FindBugs的各项检测器</a><br><a target="_blank" rel="noopener" href="https://my.oschina.net/bairrfhoinn/blog/156200">Findbugs 缺陷详解与英文代号的对照表</a></p>
<hr>
<p><strong>版权声明</strong></p>
<p><img src="https://tva1.sinaimg.cn/large/007S8ZIlgy1gee6wkfo69j30e9026gm4.jpg" alt="Creative Commons BY-NC-ND 4.0 International License"></p>
<p><a target="_blank" rel="noopener" href="http://linbinghe.me/">Lam’s Blog</a> by <a target="_blank" rel="noopener" href="http://linbinghe.me/">Binghe Lin</a> is licensed under a <a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons BY-NC-ND 4.0 International License</a>.<br>由<a target="_blank" rel="noopener" href="http://linbinghe.me/">林炳河</a>创作并维护的<a target="_blank" rel="noopener" href="http://linbinghe.me/">Lam’s Blog</a>采用<a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">创作共用保留署名-非商业-禁止演绎4.0国际许可证</a>。</p>
<p>本文首发于<a target="_blank" rel="noopener" href="http://linbinghe.me/">Lam’s Blog - Knowledeg as Action</a>，版权所有，侵权必究。</p>
<p>本文永久链接：<a target="_blank" rel="noopener" href="http://codinglife.me/2017/b2ff5786.html">http://codinglife.me/2017/b2ff5786.html</a></p>

    </div>

    
    
    

    <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/FindBugs/" rel="tag"># FindBugs</a>
              <a href="/tags/%E8%A7%84%E5%88%99/" rel="tag"># 规则</a>
              <a href="/tags/CORRECTNESS/" rel="tag"># CORRECTNESS</a>
              <a href="/tags/%E7%BF%BB%E8%AF%91/" rel="tag"># 翻译</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2017/b8a60a5e.html" rel="prev" title="FindBugs：简介与使用">
                  <i class="fa fa-chevron-left"></i> FindBugs：简介与使用
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2017/f6c077f9.html" rel="next" title="FindBugs 规则整理：Bad Practice">
                  FindBugs 规则整理：Bad Practice <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">LinBinghe</span>
</div>
  <div class="powered-by">Powered by <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/" rel="noopener" target="_blank">NexT.Gemini</a>
  </div>

    </div>
  </footer>

  
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script>

  






  





</body>
</html>
